﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace GreenWorldWinService
{
    public class Log
    {
        private static Log instance;
        private static readonly string EventLogName = "GreenWorldICEventLog";
       // private EventLog eventLog;

        private Log()
        {
            this.Initialize();
        }

        public static Log Instance
        {
            get
            {
                if ( instance == null )
                    instance = new Log();

                return instance;
            }
        }

        public void WriteInformation( string message )
        {
       //     this.eventLog.WriteEntry( message, EventLogEntryType.Warning );
        }

        public void WriteException( Exception e )
        {
            string message = String.Format("Exception - Message: {0}\n Source: {1}\n Stacktrace: {2}\n", e.Message, e.Source, e.StackTrace);
            this.WriteInformation( message );
        }

        private void Initialize()
        {
            //if ( System.Diagnostics.EventLog.SourceExists( EventLogName ) == false )
            //    System.Diagnostics.EventLog.CreateEventSource( EventLogName, "Application" );

            //this.eventLog = new EventLog();
            //this.eventLog.Source = EventLogName;
        }
    }
}
